
<%@ page import="user.entity.User" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Collections" %><%--
  Created by IntelliJ IDEA.
  User: Damon
  Date: 2021/4/23
  Time: 12:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理员</title>
</head>
<body>
</body>
<%
    String error= (String) request.getAttribute("error");
    if(error!=null){
    if(error.equals("addError")){
        out.print("此学号已被使用");
    }else if(error.equals("noAddError")){
        out.print("增加成功！");
    }
}%>
<%List<User> users= (List<User>) request.getAttribute("user");
%>
    <table border="1px">
    <tr>
    <th>学号</th>
    <th>姓&nbsp;&nbsp;&nbsp;名</th>
    <th>性别</th>
        <th>年级</th>
        <th>方向</th>

    <th>操作</th>
    </tr>
<%
    for(User user:users){if(user.getDirection().equals("前端")){%>
<tr>
    <td><a href="queryByNumServlet?uNum=<%=user.getNum() %>"><%=user.getNum() %></a>      </td>
        <td><%=user.getName() %></td>
        <td><%=user.getSex() %></td>
    <td><%=user.getGrade()%></td>
    <td><%=user.getDirection()%></td>
        <td> <a href="deleteServlet?uNum=<%=user.getNum()%>   ">删除</a> </td>
        </tr>
<%
}}
%>
        <tr><a href="uAdd.jsp">增加</a></tr>
        &nbsp;&nbsp;&nbsp;<a href="inServlet">退出登录</a>
    </table><br/>
<table border="1px">
    <%
        for(User user:users){if(user.getDirection().equals("后台")){%>
    <tr>
        <td><a href="queryByNumServlet?uNum=<%=user.getNum() %>"><%=user.getNum() %></a>      </td>
        <td><%=user.getName() %></td>
        <td><%=user.getSex() %>&nbsp;&nbsp;&nbsp;</td>
        <td><%=user.getGrade()%></td>
        <td><%=user.getDirection()%></td>
        <td> <a href="deleteServlet?uNum=<%=user.getNum()%>   ">删除</a> </td>
    </tr>
    <%}}%>
</table><br/>


<form action="query.jsp" method="post">
    以何种方式查询：<input type="radio" name="query" value="学号"/>学号&nbsp;&nbsp;&nbsp;
    <input type="radio" name="query" value="名字"/>名字&nbsp;&nbsp;&nbsp;
    <input type="radio" name="query" value="年级"/>年级<br/>
    <input type="radio" name="query" value="所有"/>所有<br/>
    <input type="submit" value="查询">

</form>

<div>
    <span id="NEXT"></span>
</div>
<script>
    function showTime(i) {
        NEXT.innerHTML = i + "秒后退出登录!";
        if (i === 0)
            window.location.href = 'inServlet';
        i--;
        if (i >= 0)
            setTimeout("showTime(" + i + ")", 1000); //每隔一秒调用showTime()函数
    }
    showTime(10*60); //倒计时十分钟
</script>
  </body>
</html>
